#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int n, m;
vector<int> d;
vector<int> p;

bool is_prime(int x)
{
    for (int i = 2; i <= sqrt(x); i++)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}
bool judg()
{
    for (int i = 0; i < d.size(); i++){
        for (int j = 0; j < d.size(); j++){
            if (i == j) continue;
            auto x = d[i]* 10 + d[j];
            if (x <= 10) continue;
            return is_prime(x);
        }
    }
    return false;
}

bool check(int x)
{
    if (x == 19) {
        int i = 0;
    }
    d.clear();
    p.clear();
    while (x)
    {
        d.emplace_back(x % 10);
        x /= 10;
    }
    return judg();
}
int main()
{
    cin >> n >> m;
    int count = 0;
    for (int i = std::max(n, 10); i <= m; i++)
    {
        if (check(i)){
            // cout << "I : " << i << endl;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}